package Utils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

public class ListUtil {
	public static ArrayList<String> merge(ArrayList<String> list1, ArrayList<String> list2) {
		ArrayList<String> result = new ArrayList<String>();
		Set<String> set = new TreeSet<String>();
		set.addAll(list1);
		set.addAll(list2);
		for (Object obj : set)
			result.add((String) obj);
		return result;
	}

	public static List<String> array2List(String[] array) {
		List<String> result = Arrays.asList(array);
		return result;
	}

	public static String[] list2Array(List<String> list) {
		return (String[]) list.toArray();
	}
	public static void main(String args[])
	{
		String [] array={"1","2","3"};
		List<String> list=ListUtil.array2List(array);
		array=ListUtil.list2Array(list);
		System.out.println(list);
		System.out.println(array[2]);
	}
}
